#pragma once

#include <sys_def.h>

typedef enum {
	TIMER_CHCTL_OUT = 0,
	TIMER_CHCTL_IN_IS0_TO_CI0FE0 = 1,
	TIMER_CHCTL_IN_IS0_TO_CI1FE0 = 2,
	TIMER_CHCTL_IN_IS0_TO_ITS = 3,
} timer_chctl_mode_e;

typedef enum {
	TIMER_CHCTL_OUT_NONE = 0,
	TIMER_CHCTL_OUT_MATCH_1 = 1,
	TIMER_CHCTL_OUT_MATCH_0 = 2,
	TIMER_CHCTL_OUT_MATCH_TOGGLE = 3,
	TIMER_CHCTL_OUT_FORCE_1 = 4,
	TIMER_CHCTL_OUT_FORCE_0 = 5,
	TIMER_CHCTL_OUT_LOWER_VALID = 6,
	TIMER_CHCTL_OUT_HIGHER_VALID = 7,
} timer_chctl_out_ctl_e;

typedef enum {
	TIMER_CHCTL_IN_FILTER_F_DTS_N_1 = 0,
	TIMER_CHCTL_IN_FILTER_F_PCLK_N_2 = 1,
	TIMER_CHCTL_IN_FILTER_F_PCLK_N_4 = 2,
	TIMER_CHCTL_IN_FILTER_F_PCLK_N_8 = 3,
	TIMER_CHCTL_IN_FILTER_F_DTS_DIV_2_N_6 = 4,
	TIMER_CHCTL_IN_FILTER_F_DTS_DIV_2_N_8 = 5,
	TIMER_CHCTL_IN_FILTER_F_DTS_DIV_4_N_6 = 6,
	TIMER_CHCTL_IN_FILTER_F_DTS_DIV_4_N_8 = 7,
	TIMER_CHCTL_IN_FILTER_F_DTS_DIV_8_N_6 = 8,
	TIMER_CHCTL_IN_FILTER_F_DTS_DIV_8_N_8 = 9,
	TIMER_CHCTL_IN_FILTER_F_DTS_DIV_16_N_5 = 10,
	TIMER_CHCTL_IN_FILTER_F_DTS_DIV_16_N_6 = 11,
	TIMER_CHCTL_IN_FILTER_F_DTS_DIV_16_N_8 = 12,
	TIMER_CHCTL_IN_FILTER_F_DTS_DIV_32_N_5 = 13,
	TIMER_CHCTL_IN_FILTER_F_DTS_DIV_32_N_6 = 14,
	TIMER_CHCTL_IN_FILTER_F_DTS_DIV_32_N_8 = 15,
} timer_chctl_in_filter_ctl_e;

typedef struct {
	__attribute__((packed)) timer_chctl_mode_e mode : 2;
	u8_s fast_en : 1;
	u8_s shadow_en : 1;
	__attribute__((packed)) timer_chctl_out_ctl_e ctl : 3;
	u8_s clear_en : 1;
} timer_chctl_out_expl_s;

_Static_assert(sizeof(timer_chctl_out_expl_s) == 1,
	       "Struct timer_chctl_out_expl_s defined error!");

typedef struct {
	__attribute__((packed)) timer_chctl_mode_e mode : 2;
	u8_s prescale_2_power : 2;
	__attribute__((packed)) timer_chctl_in_filter_ctl_e filter_ctl : 4;
} timer_chctl_in_expl_s;

_Static_assert(sizeof(timer_chctl_in_expl_s) == 1,
	       "Struct timer_chctl_in_expl_s defined error!");

typedef union {
	timer_chctl_out_expl_s chctl_out;
	timer_chctl_in_expl_s chctl_in;
} timer_chctl_byte_expl_s;

_Static_assert(sizeof(timer_chctl_byte_expl_s) == 1,
	       "Struct timer_chctl_byte_expl_s defined error!");
